package com.hongxun.design.bean.photopassbean;

import android.text.Editable;
import android.text.InputType;
import android.text.TextWatcher;

import java.util.List;

import com.hongxun.design.MyApp;
import com.hongxun.design.constant.Constant;
import com.hongxun.design.mytools.MString;
import com.hongxun.design.mytools.ToastShow;

/**
 * Created by zerdoor_pc on 2016/5/17.
 * 通道拍照——详情——图标信息
 */
public class PhotoPassIconBean {
    private String title;
    private String titleCode;
    private String value;
    private String valuecode;
    private int type;
    private String novalue;
    private List<SystemTypeBean> data;
    int inputType= InputType.TYPE_CLASS_TEXT;
    private TextWatcher textWatcher;

    public TextWatcher getTextWatcher() {
        return textWatcher;
    }

    public void setTextWatcher() {
        textWatcher=new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void afterTextChanged(Editable editable) {
                try {
                    if (MString.angle.equals(titleCode)&&editable.toString().length()>0&&Integer.parseInt(editable.toString())>360){
                        ToastShow.showShort(MyApp.activity,"角度不能大于360度");
                        value="360";
                    }else{
                        value=editable.toString();
                    }
                }catch (Exception e){}


            }
        };
    }

    public PhotoPassIconBean(int inputType,String title,String titleCode, String value, int type, List<SystemTypeBean> data) {
        this.title = title;
        this.titleCode = titleCode;
        this.inputType = inputType;
        this.value = value;
        this.type = type;
        this.data = data;
        if (type== Constant.ChoiceItem){
            novalue= MString.NoChoice;
        }
        else if (type== Constant.EdItem){
            novalue= MString.NoValue;
            setTextWatcher();
        }
    }
    public PhotoPassIconBean(){}

    public void setBean(PhotoPassIconBean bean){
        this.title = bean.getTitle();
        this.titleCode = bean.getTitleCode();
        this.value = bean.getValue();
        this.type = bean.getType();
        this.data = bean.getData();
        this.inputType = bean.getInputType();
        if (type== Constant.ChoiceItem){
            novalue= MString.NoChoice;
        }
        else if (type== Constant.EdItem){
            novalue= MString.NoValue;
            setTextWatcher();
        }
    }

    public int getInputType() {
        return inputType;
    }

    public void setInputType(int inputType) {
        this.inputType = inputType;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getNovalue() {
        return novalue;
    }

    public void setNovalue(String novalue) {
        this.novalue = novalue;
    }

    public List<SystemTypeBean> getData() {
        return data;
    }

    public void setData(List<SystemTypeBean> data) {
        this.data = data;
    }

    public String getTitleCode() {
        return titleCode;
    }

    public void setTitleCode(String titleCode) {
        this.titleCode = titleCode;
    }


    public String getValuecode() {
        return valuecode;
    }

    public void setValuecode(String valuecode) {
        this.valuecode = valuecode;
    }

}
